package com.lmh.service;

import com.lmh.dao.ApplyMapper;
import com.lmh.dao.DemandMapper;
import com.lmh.dao.LoginMapper;
import com.lmh.pojo.Demand;
import com.lmh.pojo.DemandApply;
import com.lmh.pojo.User;
import com.lmh.pojo.Userinfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class ApplyServiceImpl implements ApplyServie{

    @Autowired
    private ApplyMapper applyMapper;
    @Autowired
    private LoginMapper loginMapper;

    @Override
    public int applyadd(DemandApply demandApply) {
        return applyMapper.applyadd(demandApply);
    }

    @Override
    public List<Userinfo> applyall(String demandId) {
        List<DemandApply> demandApplies=applyMapper.applyall(demandId);

        List<Userinfo> list=new ArrayList<Userinfo>();
        for(DemandApply d:demandApplies){
            Userinfo userinfo=loginMapper.userinfoid(d.getUserId());
            list.add(userinfo);
        }
        System.out.println(list);
        return list;
    }


}
